import axios from 'axios'

export default {
  // 开启命名空间
  namespaced: true,
  state: {
    token: '',
    userInfo: {}
  },
  mutations: {
    updateToken(state, token) {
      state.token = token
    },
    updateUserInfo(state, userInfo) {
      state.userInfo = userInfo
    }
  },
  actions: {
    async getUserInfo(context) {
      const { data: res } = await axios.get('/my/userinfo')

      context.commit('updateUserInfo', res.data)
    }
  },
  getters: {}
}
